local f = -- 暗影之握监测施法
function(allstates, event, _, subEvent, _, _, sourceName, _, _, _, _, _, _,
         spellID, spellName)
    -- debug dump 
    local dump = function(...)
        if aura_env.config.debug == true then print(...) end
    end

    -- player引导的暗影之握法术id, 区分一下地狱火导魔者引导的那个
    local mySpellID = 30410
    if aura_env.config.debug then mySpellID = aura_env.config.spell_id end

    local spellAuraApplied = subEvent == "SPELL_AURA_APPLIED"
    local spellAuraRemoved = subEvent == "SPELL_AURA_REMOVED"
    local cloneLimit = 5

    if subEvent == "SPELL_AURA_APPLIED" and spellID == mySpellID and
        UnitExists(sourceName) then
        dump('aura applied, aura id is: ' .. spellID .. ' aura name is: ' ..
                 spellName .. 'player is: ' .. sourceName)
        local name, text, texture, startTimeMS, endTimeMS, isTradeSkill, spellId =
            UnitChannelInfo(sourceName)
        if name then
            dump('channeling spell name is: ' .. name)
            local duration = (endTimeMS - startTimeMS) / 1000
            local expiration = endTimeMS / 1000
            local newProgress = {
                show = true,
                changed = true,
                progressType = "timed",
                duration = duration,
                expirationTime = expiration,
                name = name,
                icon = texture,
                index = 0,
                caster = sourceName,
                autoHide = true
            }
            if #allstates >= cloneLimit then
                for _, v in pairs(allstates) do
                    v.show = false
                    v.changed = true
                end
            end
            table.insert(allstates, newProgress)
            
            return true
        end
    end
    -- 暗影之握的 buff 消失的时候, 隐藏这个player的计时条
    if subEvent == "SPELL_AURA_REMOVED" and spellID == mySpellID and
        UnitExists(sourceName) then
        dump('aura removed, aura id is: ' .. spellID .. ' aura name is: ' .. spellName .. 'player is: ' .. sourceName)
        for _, vv in pairs(allstates) do
            if vv.caster == sourceName then
                vv.changed = true
                vv.show = true
                vv.paused = true
                vv.msg = '中断！'
            end
        end

        return true
    end

    return false
end
